package com.byxx.gtz.devicemonitoringsysejb.Bean;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.byxx.gtz.devicemonitoringsysejb.Remote.FsxDeviceRemote;
import com.byxx.gtz.devicemonitoringsysejb.entity.DeviceMonitor;
import com.byxx.gtz.devicemonitoringsysejb.entity.DeviceScheme;
import com.byxx.gtz.devicemonitoringsysejb.entity.DeviceSchemeDetail;
import com.byxx.gtz.devicemonitoringsysejb.entity.Parameter;
import com.byxx.gtz.devicemonitoringsysejb.entity.Region;
import com.byxx.gtz.devicemonitoringsysejb.entity.Users;
import com.byxx.gtz.devicemonitoringsysejb.op.OpManager;

import weblogic.javaee.TransactionTimeoutSeconds;

/**
 * SessionBean
 * @author zzz
 *
 */
@Stateless(mappedName = "toolsBean")
@TransactionTimeoutSeconds(value=60)
public class FsxDeviceBean implements FsxDeviceRemote {
	
	@PersistenceContext(unitName = "toolslearn")
	private EntityManager em = null;
	private OpManager opManager = null;

	private OpManager getOpManager() {
		if (this.opManager == null) {
			this.opManager = new OpManager(this.em);
		}
		return this.opManager;
	}

	public List<Region> getAllRegion() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpRegion().getAllRegion();
	}
	
	public Region getRegion(String regionId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpRegion().getRegion(regionId);
	}
	
	public Region insertRegion(Region dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpRegion().insertRegion(dto);
	}

	public boolean updateRegion(Region dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpRegion().updateRegion(dto);
	}
	
	public boolean delectRegion(String regionId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpRegion().delectRegion(regionId);
	}
	
	
	public List<DeviceMonitor> getAllDevice() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceMonitor().getAllDevice();
	}

	public DeviceMonitor getDeviceMonitor(String deviceId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceMonitor().getDeviceMonitor(deviceId);
	}

	public boolean delectDeviceMonitor(String deviceId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceMonitor().delectDeviceMonitor(deviceId);
	}

	public boolean updateDeviceMonitor(DeviceMonitor dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceMonitor().updateDeviceMonitor(dto);
	}

	public DeviceMonitor insertDeviceMonitor(DeviceMonitor dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceMonitor().insertDeviceMonitor(dto);
	}
	

	public DeviceScheme insertDeviceScheme(DeviceScheme dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceScheme().insertDeviceScheme(dto);
	}

	public boolean delectDeviceScheme(String schemeId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceScheme().delectDeviceScheme(schemeId);
	}

	public boolean updateDeviceScheme(DeviceScheme dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceScheme().updateDeviceScheme(dto);
	}

	public DeviceScheme getDeviceScheme(String schemeId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceScheme().getDeviceScheme(schemeId);
	}

	public List<DeviceScheme> getAllDeviceScheme() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceScheme().getAllDeviceScheme();
	}

	
	public DeviceSchemeDetail insertDeviceSchemeDetail(DeviceSchemeDetail dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceSchemeDetail().insertDeviceSchemeDetail(dto);
	}

	public boolean delectDeviceSchemeDetail(String schemeId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceSchemeDetail().delectDeviceSchemeDetail(schemeId);
	}

	public boolean updateDeviceSchemeDetail(DeviceSchemeDetail dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceSchemeDetail().updateDeviceSchemeDetail(dto);
	}

	public DeviceSchemeDetail getDeviceSchemeDetail(String schemeId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceSchemeDetail().getDeviceSchemeDetail(schemeId);
	}

	public List<DeviceSchemeDetail> getAllDeviceSchemeDetail() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpDeviceSchemeDetail().getAllDeviceSchemeDetail();
	}
	

	public Parameter insertParameter(Parameter dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpParameter().insertParameter(dto);
	}

	public boolean delectParameter(String paramId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpParameter().delectParameter(paramId);
	}

	public boolean updateParameter(Parameter dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpParameter().updateParameter(dto);
	}

	public List<Parameter> getAllParameter() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpParameter().getAllParameter();
	}

	public Parameter getParameter(String paramId) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpParameter().getParameter(paramId);
	}

	public Users insertUsers(Users dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpUsers().insertUser(dto);
	}

	public boolean delectUsers(Users dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpUsers().delectUser(dto);
	}

	public boolean updateUsers(Users dto) throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpUsers().updateUser(dto);
	}

	public List<Users> getAllUsers() throws Exception {
		// TODO Auto-generated method stub
		return getOpManager().getOpUsers().getAllUsers();
	}

}